package com.hdaccp.user.service.impl;

import com.hdaccp.pojo.po.Admin;
import com.hdaccp.user.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private EntityManager entityManager;
    @Override
    public List<Admin> queryPage(int currentPage, int pageSize) {
        String jpql ="select a from Admin a";//查一个对象
        Query query=entityManager.createQuery(jpql);
        query.setFirstResult((currentPage-1)*pageSize);//从那开始 当前页-1*pageSize
        query.setMaxResults(pageSize);//到哪结束
        return query.getResultList();
    }
}
